<?php


namespace app\index\validate;


use think\Validate;

class ShopUserAddress extends Validate
{
    protected $rule = [
        'real_name' => 'require',
        'address' => 'require',
        'mobile' => 'require|isMobile',
        'city_address' => 'require',
    ];

    protected $message = [
        'real_name.require' => '姓名不能为空',
        'address.require' => '详细地址不能为空',
        'mobile.require' => '联系方式不能为空',
        'city_address.require' => '城市不能为空',


    ];

    protected function isMobile($value)
    {
        $rule = '/^1[1-9][0-9]{9}$/';
        $result = preg_match($rule, $value);
        if ($result) {
            return true;
        } else {
            return '手机号格式不正确 ';
        }
    }
}